package ilvonen.ihstatistics;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ConfirmActivity extends Activity {

	TextView _tMessage;
	Button _bYes;
	Button _bNo;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_confirm);
		setFinishOnTouchOutside (false); 
		_tMessage = (TextView)findViewById(R.id.tMessage);
		_bYes = (Button)findViewById(R.id.bYes);
		_bNo = (Button)findViewById(R.id.bNo);
		//get extras
		Bundle extras = getIntent().getExtras();
		if(extras != null){
			_tMessage.setText(extras.getString("message"));
		}
		_bYes.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent returnIntent = new Intent();
				setResult(RESULT_OK,returnIntent);     
				finish();
				
			}
		});
		_bNo.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent returnIntent = new Intent();
				setResult(RESULT_CANCELED, returnIntent);        
				finish();
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.confirm, menu);
		return true;
	}

	@Override 
	public void onBackPressed() { // prevent "back" from leaving this activity 
		
	}
}
